# =================conding: utf-8
"""
================================================================================

Author : Administrator
Created  on : 2020/11/22

E-mail: zh13997821732@163.com


================================================================================

"""
# 1.用两种方式定义一个字符串
a = str()
b = ''
print(a)
print(b)

# 2.将字符串   str_demo = “python\njava\t\php”   的转义字符关闭，交给新变量 str_new
# print('python\njava\t\php')
str_demo = r'python\njava\t\php'
str_new = str_demo
print(str_new)

# 3.定义两个变量，分别使用两种不同的字符串格式化方法，打印两条字符串
b = 20
a = '张浩'
print('用户姓名：{}, 年龄:{}'.format(a, b))
print('他叫%s' % (b))

# 4.定义一个列表，将列表转换为字符串，并赋值给新变量
list1 = [1, 2, 3, 5, '张浩']
str1 = str(list1)
print(type(str1))

# 5.将两个字符串拼接起来，赋值给新变量
a = 'py'
b = 'php'
c = a + b
print(c)
print(type(c))

# 6.定义字符串  a = ‘py’    b = ‘python’  判断一下a是否是b的成员
a = 'py'
b = 'python'
if a in b:
    print('OK')
else:
    print('fail')

# 7.定义一个字符串，并将字符串内容转换为大写
a = 'pyHHH'
a = a.upper()
print(a)

# 8.定义一个字符串，并将字符串内容转换为小写
a = 'HHHHH'
a = a.lower()
print(a)

# 9.定义一个首尾有空格的字符串，并使用strip方法，将空格去除
a = '  py'
a = a.strip()
print(a)

# 10. 定义一个字符串，查找字符串中某个元素的位置 找不到返回-1
a = 'helloword'
print(a.find('a'))

# 11. 定义字符串  a = ‘python/java/c’    使用split方法将字符串分割，得到列表  [‘python’, ’ java’, ‘c’]
a = 'python/java/c'
print(a.split('/'))

# 12. 定义一个字符串，查找字符串中某个元素的个数
a = "helloword"
print(a.count('h'))
# j = 0
# for i in a:
#     if i == 'l':
#         j += 1
# print(j)

# 13. 定义字符串  a = ‘I like java’   使用replace方法将字符串中的java替换成 python
a = 'I like java'
print(a.replace('java', 'python'))
# 14. 使用join方法拼接字符串
a = 'python'
b = a.join('ooo')
print(b)

# print(type('aaa'))
# print(type([1, 2]))

